package com.bite.ioc.controller;

import com.bite.ioc.config.StudentConfig;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@ResponseBody
@Controller
public class YmlController {
    @Value("${spring.datasource.url}")
    public String url;

    @Value("${spring.datasource.username}")
    public String username;

    @Value("${yml.value}")
    public String ymlValue;

    @Value("${string.str1}")
    public String str1;

    @Value("${string.str2}")
    public String str2;

    @Value("${string.str3}")
    public String str3;

    @Autowired
    public StudentConfig studentConfig;

    @PostConstruct
    public void readValue(){
//        System.out.println("YmlController.url:"+url);
//        System.out.println("YmlController.username:"+username);
//        System.out.println("YmlController.username:"+ymlValue);
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
    }

    @RequestMapping("/readObject")
    public String readObject(){
        return studentConfig.toString();
    }

}
